﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Threading;

namespace RCT2
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {

            if (args.Length > 1 && args[1] == "wait")
                Thread.Sleep(1000);
            bool createdNew;
            Mutex mutex = new Mutex(true, "{351421D9-C72F-4634-9432-A53845E3B623}", out createdNew);
            if (!createdNew)
            {
                MessageBox.Show("Only one instance of RCT2 can run at a time.", "RCT2", MessageBoxButtons.OK);
                return;
            }

            if (File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\RCT2_old.exe"))
                File.Delete(Path.GetDirectoryName(Application.ExecutablePath) + "\\RCT2_old.exe");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Bars());
            GC.KeepAlive(mutex);
        }
    }
}
